package com.job.project.config;

import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.stereotype.Component;

/**
 * @Author 王博
 * @DateTime 2024-07-04 17:22
 */
@Component
public class MyThreadPoolScheduleConfigurer implements SchedulingConfigurer {
    @Override
    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
        ThreadPoolTaskScheduler executor = new ThreadPoolTaskScheduler();
        executor.setPoolSize(100);
        executor.setThreadGroupName("schedule线程池");
        executor.setThreadNamePrefix("schedule-");
        executor.initialize();
        scheduledTaskRegistrar.setTaskScheduler(executor);
    }
}

